import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

// 路由
import router from './router/index.js'
// ElementPlus UI
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// axios
import axios from 'axios'
// echarts
import ECharts from 'vue-echarts'
import "echarts"
// Store 状态管理
import store from './store/index.js'
// 字体包
import "./fonts/font.css"
// icon
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入css    
import 'swiper/swiper-bundle.css';

const app = createApp(App).component('e-charts', ECharts).use(router).use(ElementPlus).use(store)

// 统一注册icon图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// console.log(app.config)
axios.defaults.baseURL="http://localhost:8080"

//设置一个拦截器，在请求头添加token信息
axios.interceptors.request.use(
    config=>{
        if(localStorage.getItem('token')){
            config.headers.Authorization=localStorage.getItem('token');
        }
        return config;
    },
    error=>{
        return Promise.reject(error);
    }
)
app.config.globalProperties.$http=axios  // 请求设置为全局属性
app.config.globalProperties.$router=router
app.mount('#app')
// app.config.globalProperties.$router=router



